package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.exception.PasswordException;
import com.cskaoyan.exception.UsernameException;
import com.cskaoyan.exception.YuanzhiException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("auth")
@RestController
public class AuthController {

    @RequestMapping("login")
    public BaseRespVo login(String username, String password) throws Exception {
        if (username.length() > 10) {
            throw new UsernameException();
        }
        if (password.length() < 6) {
            throw new PasswordException();
        }
        if ("yuanzhi".equals(username) || "yuanzhi".equals(password)) {
            throw  new YuanzhiException();
        }
        return BaseRespVo.ok();
    }
}
